home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / winterp-1.13 / src-server / wc_ArrowB.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-04  |  7.6 KB  |  190 lines

  1. /* -*-C-*-
  2. ********************************************************************************
  3. *
  4. * File:         wc_ArrowB.c
  5. * RCS:          $Header: wc_ArrowB.c,v 1.3 91/03/14 03:14:25 mayer Exp $
  6. * Description:  XM_ARROW_BUTTON_WIDGET_CLASS/XM_ARROW_BUTTON_GADGET_CLASS
  7. * Author:       Niels Mayer, HPLabs
  8. * Created:      Fri Oct 27 21:36:45 1989
  9. * Modified:     Thu Oct  3 23:57:05 1991 (Niels Mayer) mayer@hplnpm
  10. * Language:     C
  11. * Package:      N/A
  12. * Status:       X11r5 contrib tape release
  13. *
  14. * WINTERP Copyright 1989, 1990, 1991 Hewlett-Packard Company (by Niels Mayer).
  15. * XLISP version 2.1, Copyright (c) 1989, by David Betz.
  16. *
  17. * Permission to use, copy, modify, distribute, and sell this software and its
  18. * documentation for any purpose is hereby granted without fee, provided that
  19. * the above copyright notice appear in all copies and that both that
  20. * copyright notice and this permission notice appear in supporting
  21. * documentation, and that the name of Hewlett-Packard and David Betz not be
  22. * used in advertising or publicity pertaining to distribution of the software
  23. * without specific, written prior permission.  Hewlett-Packard and David Betz
  24. * make no representations about the suitability of this software for any
  25. * purpose. It is provided "as is" without express or implied warranty.
  26. *
  27. * HEWLETT-PACKARD AND DAVID BETZ DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  28. * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
  29. * IN NO EVENT SHALL HEWLETT-PACKARD NOR DAVID BETZ BE LIABLE FOR ANY SPECIAL,
  30. * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  31. * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  32. * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  33. * PERFORMANCE OF THIS SOFTWARE.
  34. *
  35. * See ./winterp/COPYRIGHT for information on contacting the authors.
  36. * Please send modifications, improvements and bugfixes to mayer@hplabs.hp.com
  37. * Post XLISP-specific questions/information to the newsgroup comp.lang.lisp.x
  38. *
  39. ********************************************************************************
  40. */
  41. static char rcs_identity[] = "@(#)$Header: wc_ArrowB.c,v 1.3 91/03/14 03:14:25 mayer Exp $";
  42.  
  43. #include <stdio.h>
  44. #include <Xm/Xm.h>
  45. #include <Xm/ArrowB.h>
  46. #include <Xm/ArrowBG.h>
  47. #include "winterp.h"
  48. #include "user_prefs.h"
  49. #include "xlisp/xlisp.h"
  50. #include "w_funtab.h"
  51.  
  52.  
  53. #ifdef WINTERP_MOTIF_11
  54. /******************************************************************************
  55.  * typedef struct
  56.  * {
  57.  *     int     reason;
  58.  *     XEvent  *event;
  59.  *     int        click_count;
  60.  * } XmArrowButtonCallbackStruct;
  61.  ******************************************************************************/
  62. static void Lexical_Bindings_For_XmArrowButtonCallbackStruct(bindings_list, lexical_env, cd, o_widget)
  63.      LVAL bindings_list;    /* a list of symbols to which values from XmArrowButtonCallbackStruct are bound */
  64.      LVAL lexical_env;        
  65.      XmArrowButtonCallbackStruct* cd;
  66.      LVAL o_widget;        /* XLTYPE_WIDGETOBJ */
  67. {
  68.   extern LVAL s_CALLBACK_WIDGET, s_CALLBACK_REASON, s_CALLBACK_XEVENT, s_CALLBACK_CLICK_COUNT; /* w_callbacks.c */
  69.   extern LVAL Wcb_Get_Callback_Reason_Symbol();    /* w_callbacks.c */
  70.   register LVAL s_bindname;
  71.  
  72.   for ( ; consp(bindings_list); bindings_list = cdr(bindings_list)) {
  73.  
  74.     s_bindname = car(bindings_list);
  75.  
  76.     if (s_bindname == s_CALLBACK_WIDGET) {
  77.       xlpbind(s_bindname, o_widget, lexical_env);
  78.     }
  79.     else if (s_bindname == s_CALLBACK_REASON) {
  80.       xlpbind(s_bindname, Wcb_Get_Callback_Reason_Symbol(cd->reason), lexical_env);
  81.     }
  82.     else if (s_bindname == s_CALLBACK_XEVENT) {
  83.       xlpbind(s_bindname, (cd->event) ? cv_xevent(cd->event) : NIL, lexical_env);
  84.     }
  85.     else if (s_bindname == s_CALLBACK_CLICK_COUNT) {
  86.       xlpbind(s_bindname, cvfixnum((FIXTYPE) (cd->click_count)), lexical_env);
  87.     }
  88.     else {
  89.       extern char temptext[];    /* from winterp.c */
  90.       sprintf(temptext,
  91.           "Unknown binding name in XmArrowButtonCallbackStruct callback evaluator. Valid symbols are [%s %s %s %s].",
  92.           (char*) getstring(getpname(s_CALLBACK_WIDGET)),
  93.           (char*) getstring(getpname(s_CALLBACK_REASON)),
  94.           (char*) getstring(getpname(s_CALLBACK_XEVENT)),
  95.           (char*) getstring(getpname(s_CALLBACK_CLICK_COUNT)));
  96.       xlerror(temptext, s_bindname);
  97.     }
  98.   }
  99. }
  100.  
  101. /******************************************************************************
  102.  * This is called indirectly via XtAddCallback() for callbacks returning
  103.  * an XmArrowButtonCallbackStruct as call_data.
  104.  ******************************************************************************/
  105. static void XmArrowButtonCallbackStruct_Callbackproc(widget, client_data, call_data)
  106.      Widget    widget;
  107.      XtPointer client_data;
  108.      XtPointer call_data;
  109. {
  110.   extern void Wcb_Meta_Callbackproc();    /* w_callbacks.c */
  111.  
  112.   Wcb_Meta_Callbackproc(client_data, call_data,
  113.             Lexical_Bindings_For_XmArrowButtonCallbackStruct,
  114.             NULL);
  115. }
  116.  
  117. /******************************************************************************
  118.  * Same as WIDGET_CLASS's :add_callback method except that this understands
  119.  * how to get values from the XmArrowButtonCallbackStruct.
  120.  * Specifying one or more of the following symbols in the callback bindings 
  121.  * list will bind that symbol's value in the lexical environment of the callback:
  122.  * CALLBACK_WIDGET
  123.  * CALLBACK_REASON
  124.  * CALLBACK_XEVENT
  125.  * CALLBACK_CLICK_COUNT -- new for motif 1.1
  126.  ******************************************************************************/
  127. LVAL Xm_Arrow_Button_Widget_Class_Method_ADD_CALLBACK()
  128. {
  129.   extern LVAL Wcb_Meta_Method_Add_Callback(); /* w_callbacks.c */
  130.  
  131.   return (Wcb_Meta_Method_Add_Callback(XmArrowButtonCallbackStruct_Callbackproc, FALSE));
  132. }
  133.  
  134.  
  135. /******************************************************************************
  136.  * Same as WIDGET_CLASS's :set_callback method except that this understands
  137.  * how to get values from the XmArrowButtonCallbackStruct.
  138.  * Specifying one or more of the following symbols in the callback bindings 
  139.  * list will bind that symbol's value in the lexical environment of the callback:
  140.  * CALLBACK_WIDGET
  141.  * CALLBACK_REASON
  142.  * CALLBACK_XEVENT
  143.  * CALLBACK_CLICK_COUNT -- new for motif 1.1
  144.  ******************************************************************************/
  145. LVAL Xm_Arrow_Button_Widget_Class_Method_SET_CALLBACK()
  146. {
  147.   extern LVAL Wcb_Meta_Method_Add_Callback(); /* w_callbacks.c */
  148.  
  149.   return (Wcb_Meta_Method_Add_Callback(XmArrowButtonCallbackStruct_Callbackproc, TRUE));
  150. }
  151. #endif                /* WINTERP_MOTIF_11 */
  152.  
  153.  
  154. /******************************************************************************
  155.  *
  156.  ******************************************************************************/
  157. Wc_ArrowB_Init()
  158. {
  159.   LVAL o_XM_ARROW_BUTTON_WIDGET_CLASS;
  160.   LVAL o_XM_ARROW_BUTTON_GADGET_CLASS;
  161.   extern LVAL Wcls_Create_Subclass_Of_WIDGET_CLASS(); /* w_classes.c */
  162.   extern      xladdmsg();    /* from xlobj.c */
  163.  
  164.   o_XM_ARROW_BUTTON_WIDGET_CLASS = 
  165.     Wcls_Create_Subclass_Of_WIDGET_CLASS("XM_ARROW_BUTTON_WIDGET_CLASS",
  166.                      xmArrowButtonWidgetClass);
  167.  
  168. #ifdef WINTERP_MOTIF_11
  169.   xladdmsg(o_XM_ARROW_BUTTON_WIDGET_CLASS, ":ADD_CALLBACK",
  170.            FTAB_Xm_Arrow_Button_Widget_Class_Method_ADD_CALLBACK);
  171.  
  172.   xladdmsg(o_XM_ARROW_BUTTON_WIDGET_CLASS, ":SET_CALLBACK",
  173.            FTAB_Xm_Arrow_Button_Widget_Class_Method_SET_CALLBACK);
  174. #endif                /* WINTERP_MOTIF_11 */
  175.  
  176.   o_XM_ARROW_BUTTON_GADGET_CLASS =
  177.     Wcls_Create_Subclass_Of_WIDGET_CLASS("XM_ARROW_BUTTON_GADGET_CLASS",
  178.                      xmArrowButtonGadgetClass);
  179.  
  180. #ifdef WINTERP_MOTIF_11
  181.   xladdmsg(o_XM_ARROW_BUTTON_GADGET_CLASS, ":ADD_CALLBACK",
  182.            FTAB_Xm_Arrow_Button_Widget_Class_Method_ADD_CALLBACK);
  183.   
  184.   xladdmsg(o_XM_ARROW_BUTTON_GADGET_CLASS, ":SET_CALLBACK",
  185.            FTAB_Xm_Arrow_Button_Widget_Class_Method_SET_CALLBACK);
  186. #endif                /* WINTERP_MOTIF_11 */
  187.  
  188. }
  189.